{extend name="public/menu2" /}
{block name='title'}-{$cur.name}{/block}

{block name='content'}
<div class="teacher">
<!--内容-->
<div class="teacher_content">

    <div class="apply_content">

        <div class="apply_title">
            <h5>{:setting('company')}</h5>
            <p>{:setting('company_en')}</p>
        </div>

        <div class="apply_form">

            <div class="form_left">
                <ul>
                    {php}$list = json_decode(setting('list'),true);{/php}
                    {foreach $list as $k=>$l}
                    <li>
                        <img src="{$l.thumb ?: ''}" />
                        <div class="form_brief">
                            <h5>{$l.name ?: ''}</h5>
                            <p>{$l.value ?: ''}</p>
                        </div>
                    </li>
                    {/foreach}
                </ul>
            </div>

            <form class="form_right" onsubmit="">
                <div class="form_list">
                    <div class="form_content">
                        <span>姓名</span>
                        <input type="text" name="name" placeholder="" />
                    </div>
                    <div class="form_content">
                        <span>性别</span>
                        <select name="sex">
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>
                    </div>
                    <div class="form_content">
                        <span>课程类型</span>
                        <select name="type">
                            <option>学校集体课程</option>
                        </select>
                    </div>
                    <div class="form_content">
                        <span>联系方式</span>
                        <input type="text" name="link" placeholder="" />
                    </div>
                    <div class="form_content">
                        <span>年龄段</span>
                        <input type="text" name="age" placeholder="" />
                    </div>
                    <div class="form_content">
                        <span>所在学校</span>
                        <input type="text" name="school" placeholder="" />
                    </div>
                    <div class="form_content">
                        <textarea placeholder="留言" name="content"></textarea>
                    </div>
                </div>
                <button class="btn" type="button">提交</button>
            </form>
        </div>

    </div>

</div>
</div>
</div>
{/block}

{block name='script'}
<link rel="stylesheet" type="text/css" href="__STATIC__/index/css/reset.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/index/css/teacher.css" />
<script>
    $(function () {

        $('.btn').on('click',function () {
            var name = $('[name="name"]').val();
            var sex = $('[name="sex"]').val();
            var type = $('[name="type"]').val();
            var link = $('[name="link"]').val();
            var age = $('[name="age"]').val();
            var school = $('[name="school"]').val();
            var content = $('[name="content"]').val();
            var arr = [name,sex,type,link,age,school,content];
            var key = ['name','sex','type','link','age','school','content'];
            for ( var i = 0; i <arr.length; i++){
                if (arr[i]==''){
                    $('[name="'+key[i]+'"]').focus();
                    return false;
                }
            }
            $.ajax({
                url:'{:url("/apply3")}',
                type:'post',
                data:{name:name,sex:sex,type:type,link:link,age:age,school:school,content:content,lesson_id:"{$lesson_id ?: ''}"},
                success:function (res) {
                    if(res.code==1){
                        alert('提交成功！');
                        location.reload();
                    }else if(res.code=='busy'){
                        alert('您操作太频繁啦，稍后再来吧！');
                    }else {
                        $('[name="'+res.code+'"]').focus();
                    }
                }
            })
        })
    })
</script>

{/block}